﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

using log4net;
using ThanhCongJSC.Helper;
using Microsoft.Web.Mvc;

namespace ThanhCongJSC
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        private static ILog _logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    "MvcRoute",                      // Route name
            //    "{controller}/{action}/{id}",         // URL with parameters
            //    new { controller = "Admin", action = "Index", id = "" } // Parameter defaults            
            //);

            routes.MapRoute(
                "MyRoute",                      // Route name
                "Admin/{action}/{id}",         // URL with parameters
                new { controller = "Admin", action = "Index", id = "" } // Parameter defaults            
            );

            routes.MapRoute(
                "Default", // Route name
                "{queryString}", // URL with parameters
                new { controller = "Home", action = "Index", queryString = UrlParameter.Optional } // Parameter defaults
            );
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
            ValueProviderFactories.Factories.Add(new JsonValueProviderFactory());

            log4net.Config.XmlConfigurator.Configure();
            _logger.Info("Application_Start ....");

            string root = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;
            if (root.Equals("/"))
                root = string.Empty;
            Application["Root"] = root;

            //  Gioi Thieu and sub menus
            Constant.QueryStringStatic.Add(Constant.QueryStringTrangChu, "GioiThieu");
            Constant.QueryStringStatic.Add(Constant.QueryStringGioiThieu, "GioiThieu");
            Constant.QueryStringStatic.Add(Constant.QueryStringCoCauToChuc, "CoCauToChuc");
            Constant.QueryStringStatic.Add(Constant.QueryStringChinhSachChatLuong, "ChinhSachChatLuong");
            Constant.QueryStringStatic.Add(Constant.QueryStringPhuongChamHanhDong, "VanHoaDoanhNghiep");
            // Constant.QueryStringStatic.Add(Constant.QueryStringTrangChu, "GioiThieu");
            // Linh Vuc and Sub Menus
            Constant.QueryStringStatic.Add(Constant.QueryStringKhaoSatDiaHinhDiaChat, "KhaoSatDiaHinhDiaChat");
            Constant.QueryStringStatic.Add(Constant.QueryStringTuVanThieKeCongTrinhGiaoThongDanDungKienTrucThuyLoiCang, "TuVanThietKe");
            Constant.QueryStringStatic.Add(Constant.QueryStringThiNghiemVaKiemTraCongTrinhLas459, "ThiNghiemKiemTra");
            Constant.QueryStringStatic.Add(Constant.QueryStringThiCong, "ThiCong");
            //  Lien He
            Constant.QueryStringStatic.Add(Constant.QueryStringLienHe, "LienHe");
            //Doi tac nuoc ngoai

            Constant.QueryStringStatic.Add(Constant.QueryStringDTNuocNgoai, "DTNuocNgoai");

            //  Tin Tuc
            Constant.QueryStringTinTuc.Add(Constant.QueryStringTinTucDuAn);
            Constant.QueryStringTinTuc.Add(Constant.QueryStringTinTucHoatDongNoiBo);
            //  Du An
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDaHTVeCungCapNS);
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDaHTVeKhaoSatDHDC);
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDaHTVeThiNghiem);
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDangTHVeCungCapNS);
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDangTHVeKhaoSatDHDC);
            Constant.QueryStringDuAn.Add(Constant.QueryStringDuAnDangTHVeThiNghiem);
            //  Tuyen Dung
            Constant.QueryStringTuyenDung.Add(Constant.QueryStringTuyenDungTrongCoCauCongTy);
            Constant.QueryStringTuyenDung.Add(Constant.QueryStringTuyenDungLamViecTheoCacDuAn);
            Constant.QueryStringTuyenDung.Add(Constant.QueryStringDichVuTuyenDung);
        }

        protected void Session_Start()
        {
            Session["CultureInfo"] = "";
        }
    }
}